package com.chinaztt.fda.http;

import java.util.HashMap;

public class GlobalVar{
	private static final String TAG = new Throwable().getStackTrace()[0].getClassName();
	
	private HashMap<String, Object> mapContain = new HashMap<String, Object>();
	
	private static GlobalVar mInstance = null;

	private GlobalVar() {
	}

	public static GlobalVar getInstance() {
		if (mInstance == null)
			mInstance = new GlobalVar();
		return mInstance;
	}
	
	public void clear(){
		mapContain.clear();
	}
	public void remove(String key){
		mapContain.remove(key);
	}
	
	public void setObjectValue(String key, Object data){
		mapContain.put(key, data);
	}
	
	public void setStringValue(String key, String data){
		mapContain.put(key, data);
	}
	
	public String getStringValue(String key,String defaultString) {
		String valueStr = defaultString;
		Object tempObj = mapContain.get(key);
		if(tempObj!=null && tempObj instanceof String) {
			valueStr = tempObj.toString();
		}
		return valueStr;
	}
	
	protected Object getValue(String key){
		Object tempObj = mapContain.get(key);
		if(tempObj==null) {
			tempObj = new Object();
		}
		return tempObj;
	}
	
	
}
